import 'dart:core';
import 'widget_custom_radio.dart';
import 'package:flutter/material.dart';

// ignore: must_be_immutable
class SwitchChoiceItemWidget extends StatelessWidget {
  final bool open;
  final bool isLine;
  final String title;
  final String leftText;
  final String rightText;
  final Function tapCallback;

  SwitchChoiceItemWidget(
      {this.title,
      this.open = true,
      this.isLine,
      this.leftText,
      this.rightText,
      this.tapCallback});

  @override
  Widget build(BuildContext context) {
    return buildWidgetItem(context);
  }

  Widget buildWidgetItem(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        children: <Widget>[
          Container(
            height: 48,
            padding: EdgeInsets.only(left: 16, right: 16),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                Container(
                  width: 110,
                  child:Text(title??"",textAlign:TextAlign.left,style: TextStyle(color: Color(0xff666666),fontSize: 14),),
                ),
                Spacer(),
                CustomRadioWidget(
                  open: this.open,
                  leftText: leftText,
                  rightText: rightText,
                  checkListener: tapCallback,
                ),
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.only(left: 16),
            child: Offstage(
              offstage: !isLine,
              child: Container(
                height: 0.5,
                color: Color(0xffebebeb),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
